#include "head.h"

int init_tcp(int *socketfd, char *ip, char *port){
    *socketfd = socket(AF_INET, SOCK_STREAM, 0);
    struct sockaddr_in addr;
    addr.sin_family = AF_INET;
    addr.sin_port = htons(atoi(port));
    addr.sin_addr.s_addr = inet_addr(ip);
    int reuse = 1;
    setsockopt(*socketfd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));
    bind(*socketfd,(struct sockaddr *)&addr, sizeof(addr));
    listen(*socketfd, 10);
    return 0;
}

